﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Master.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UI.Admin.Role.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" href="/Admin/assets/css/jquery-ui-1.10.3.full.min.css" />
    <script>
        function summit_delete_role(ID) {
            $("#dialog-confirm").removeClass('hide').dialog({
                resizable: false,
                modal: true,
                title: "<div class='widget-header'><h4 class='smaller'><i class='icon-warning-sign red'></i>删除用户</h4></div>",
                title_html: true,
                buttons: [
                    {
                        html: "<i class='icon-trash'></i>&nbsp; 删除",
                        "class": "btn btn-danger btn-xs",
                        click: function () {
                            var s = "";
                            s = $.ajax({
                                type: "POST",
                                url: "AjaxAction.ashx",
                                data: {
                                    ID: ID,
                                    dowhat: "delete_role",
                                },
                                async: false
                            }).responseText;
                            if (s == "success") {
                                window.location.href = "Default.aspx" + location.search;
                            }
                        }
                    }
                    ,
                    {
                        html: "<i class='icon-remove'></i>&nbsp; 取消",
                        "class": "btn btn-xs",
                        click: function () {
                            $(this).dialog("close");
                        }
                    }
                ]
            });
        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div class="row">
	    <div class="col-xs-12">
           
		    <h3 class="header smaller lighter purple">角色列表&nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-purple btn-sm" href="Create.aspx"><i class="icon-plus"></i>添加角色</a></h3>
		    <div class="table-header badge-purple">
			    通过建立拥有不同权限的角色，可以对系统进行分级管理。
		    </div>

		    <div class="table-responsive">
			    <table id="sample-table-2" class="table table-striped table-bordered table-hover">
				    <thead>
					    <tr>
						    <th class="center">
							    <label>
                                    
								    <input type="checkbox" class="ace" />
								    <span class="lbl"></span>
							    </label>
						    </th>
						    <th>ID</th>
                            <th>角色名称</th>				
						    <th>状态</th>
						    <th>管理员</th>
						    <th>模型权限</th>                        
						    <th>用户权限</th>
                            <th>角色权限</th>
                            <th>日志权限</th>
                            <th>系统权限</th>
                             <th>栏目权限</th>
                            <th>文件权限</th>
                            <th>内容权限</th>
                            <th></th>
					    </tr>
				    </thead>

				    <tbody>
                 <%if(roleList!=null){ %>
                     <%for(int i=0;i<roleList.Count;i++){ %>
					    <tr>
						    <td class="center">
							    <label>
								    <input type="checkbox" class="ace" />
								    <span class="lbl"></span>
							    </label>
						    </td>

						    <td><%=roleList[i].ID %></td>
						    <td><%=roleList[i].Name %></td>
						    <td><%=roleList[i].RoleEnabled?"可用":"不可用"%></td>
						    <td><%=roleList[i].IsAdmin?"管理员":"用户" %></td>
						    <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].ModelAdmin?"ok":"remove" %>'></i></span></td>
                            <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].UserAdmin?"ok":"remove" %>'></i></span></td>
						    <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].RoleAdmin?"ok":"remove" %>'></i></span></td>
						    <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].LogAdmin?"ok":"remove" %>'></i></span></td>
						    <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].SystemAdmin?"ok":"remove" %>'></i></span></td>
						    <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].ColumnAdmin?"ok":"remove" %>'></i></span></td>
                            <td><span class="label label-purple arrowed"><i class='icon-<%=roleList[i].FileAdmin?"ok":"remove" %>'></i></span></td>
                            <td></td>
						    <td>
							    <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
							

								    <a class="green" href="Update.aspx?ID=<%=roleList[i].ID%>">
									    <i class="icon-pencil bigger-130"></i>
								    </a>

								    <a class="red" href="javascript:void(0)" onclick="summit_delete_role('<%=roleList[i].ID %>')">
									    <i class="icon-trash bigger-130"></i>
								    </a>
							    </div>
						    </td>
					    </tr>
	                    <%} %>
                    <%} %>
				    </tbody>
			    </table>
		    </div>
	    </div>
    </div>

    <div id="dialog-confirm" class="hide">
		<div class="alert alert-info bigger-110">
			删除操作执行后不可恢复
		</div>

		<div class="space-6"></div>

		<p class="bigger-110 bolder center grey">
			<i class="icon-hand-right blue bigger-120"></i>
			Are you sure?
		</p>
	</div><!-- #dialog-confirm -->
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <script src="/Admin/assets/js/jquery.dataTables.min.js" charset="GB2312"></script>
	<script src="/Admin/assets/js/jquery.dataTables.bootstrap.js" charset="GB2312"></script>
    <script src="/Admin/assets/js/jquery-ui-1.10.3.full.min.js"></script>
	<script src="/Admin/assets/js/jquery.ui.touch-punch.min.js"></script>

    <script type="text/javascript">
        jQuery(function ($) {
            var oTable1 = $('#sample-table-2').dataTable({
                "aoColumns": [
			      { "bSortable": false },
			      null, null, null, null, null, null, null, null, null, null, null, null,
				  { "bSortable": false }
                ]
            });


            $('table th input:checkbox').on('click', function () {
                var that = this;
                $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

            });


            $('[data-rel="tooltip"]').tooltip({ placement: tooltip_placement });
            function tooltip_placement(context, source) {
                var $source = $(source);
                var $parent = $source.closest('table')
                var off1 = $parent.offset();
                var w1 = $parent.width();

                var off2 = $source.offset();
                var w2 = $source.width();

                if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
                return 'left';
            }
        })

        $.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
            _title: function (title) {
                var $title = this.options.title || '&nbsp;'
                if (("title_html" in this.options) && this.options.title_html == true)
                    title.html($title);
                else title.text($title);
            }
        }));
		</script>
</asp:Content>
